//////////////////////////////////////////////////////////////////////////////
//       Copyright (c) 2003 - RealTime Gaming.  All rights reserved.        //
//////////////////////////////////////////////////////////////////////////////

#ifndef STRTABLEMGR_H
#define STRTABLEMGR_H

//////////////////////////////////////////////////////////////////////////////
// Includes
//////////////////////////////////////////////////////////////////////////////
#include "lib.h"
#include "list.h"
#include "StrTable.h"
#include "KeywordSubstitutor.h"
#include "LocaleFormatter.h"

//////////////////////////////////////////////////////////////////////////////
// Declare Namespace
//////////////////////////////////////////////////////////////////////////////
namespace Library
{

//////////////////////////////////////////////////////////////////////////////
/// StrTableMgr class. Manages String Table resources.
//////////////////////////////////////////////////////////////////////////////
class PLIBEXP StrTableMgr
{
// Public Interface
public:
	// Construction/Destruction
	StrTableMgr( KeywordSubstitutor* pSubstitutor, LocaleFormatter* pFormatter );
	~StrTableMgr();

	// Add/Remove Tables
	bool8 LoadTableFromResource( const String& sTableName );
	bool8 CreateTable( const String& sTableName );
	bool8 ReleaseTable( const String& sTableName );
    bool8 ClearTable( const String& sTableName );

	// Get Strings
	const String& GetString( const String& sTableName, const String& sShortName );
	const String& GetString( const String& sShortName );

	// Add/Remove individual strings
	bool8 AddString( const String& sTableName, const String& sShortName, const String& string );
	bool8 RemoveString( const String& sTableName, const String& sShortName );

	// Allow direct access to our internal keyword substitutor object
	KeywordSubstitutor* GetKeywordSubstitutor();

// Internal Helpers
protected:
	StrTable* FindTable( const String& sTableName );
	const String& GetStringWithSubstition( const StrTable* pTable, const String& sShortName );

// Members
protected:
	List<StrTable*>*	 m_plistTables;	    /**< Internal List of string tables        */
	String				 m_sEmpty;		    /**< Empty string, when request not found  */
    KeywordSubstitutor*  m_pSubstitutor;    /**< Internal pointer to keyword sub       */
    LocaleFormatter*     m_pFormatter;      /**< Internal pointer to locale formatter  */

private:
    // Hide the default constructor, you must use the constructor above!!!
    StrTableMgr();
};

} // namespace Library

#endif //#ifndef STRTABLEMGR_H
